package ewu

import ewu._

/**
 * Diese Klasse erbt von der Comparison-Klasse und
 * stellt einen Gleichheitsvergleich dar.
 * Beispiel: x = y
 */

case class Equal (left: Expression, right: Expression) extends Comparison {
  
  def evaluate (env: Environment): Option[Boolean] =
                                    (left.evaluate(env), right.evaluate(env)) match {
    case (Some(le), Some(ri)) => Some(le == ri)
    case _ => None
  }

  override def toString: String = left + " = " + right

  def reduce: BoolExpression = Equal(left.reduce, right.reduce)

  def isTrue: Boolean = left.reduce equals right.reduce
  
}


 